// ****************************************************************
// Copyright 2012, Stephan Burguchev
// e-mail: me@sburg.net
// ****************************************************************
// *
using System.IO;
using NUnit.Framework;
using Updater.Common;
using Updater.Updates;

namespace Updater.Tests
{
    [TestFixture]
    public class UpdatesRssFeedReaderTests
    {
        [Test]
        public void Read_SimpleUpdatesRssFeed()
        {
            string testData = Config.TestDataDirectory;
            string rssFilename = Path.Combine(testData, "simple-updates-rss.xml");

            var reader = new UpdatesRssFeedReader();
            UpdateInformation[] updates;
            using (FileStream stream = File.OpenRead(rssFilename))
            {
                updates = reader.Read(stream);
            }

            Assert.AreEqual(3, updates.Length);
        }

        [Test]
        public void Read_ValidUpdatesRssFeedWithOmittedAttributes()
        {
            string testData = Config.TestDataDirectory;
            string rssFilename = Path.Combine(testData, "omitted-attributes-updates-rss.xml");

            var reader = new UpdatesRssFeedReader();
            UpdateInformation[] updates;
            using (FileStream stream = File.OpenRead(rssFilename))
            {
                updates = reader.Read(stream);
            }

            Assert.AreEqual(1, updates.Length);
        }
    }
}
